//
// itertool - a polynormial and type-safe iterator framework in C++.
//
// Copyright (c) 2021-2025 Feng Cong
//
// Distributed under the MIT Software License
// See accompanying file LICENSE.txt or copy at
// https://opensource.org/licenses/MIT

#include <itertool/iter/chain.h>

#include <numeric>

#include "itertool_test.h"

TEST_CASE("Chain(initializer_list<Iterator<T>>) signiture") {
  auto single = itertool_test::NaturalNumber(10);

  auto it = itertool::Chain({
      itertool_test::NaturalNumber(10),
      itertool_test::NaturalNumber(10),
      itertool_test::NaturalNumber(10),
  });

  SUBCASE("the sum of the chained iterators") {
    const int kSum = std::accumulate(single.begin(), single.end(), int(0)) * 3;
    int sum = std::accumulate(it.begin(), it.end(), int(0));
    CHECK_EQ(sum, kSum);
  }

  SUBCASE("the total number of items of the chained iterators") {
    const int kTotal = std::distance(single.begin(), single.end()) * 3;
    auto tot = std::distance(it.begin(), it.end());
    CHECK_EQ(tot, kTotal);
  }

  SUBCASE("length hint of chain iterator") {
    CHECK_EQ(it.LengthHint(), 3 * single.LengthHint());
  }
}

TEST_CASE("Chain(Iterator<Iterator<T>>) signiture") {}